from django.shortcuts import render
from django.http import HttpResponse
from .models import Article,Category


def index(request):
    # article = Article.objects.get(pk=1)
    # print(article.title)
    # 加不加都一样
    # article = Article.objects.get(title__iexact="西游记")

    # article = Article.objects.filter(title__contains="游")
    #
    # article = Article.objects.filter(id__in=[1, 2, 3])
    # print(article.query)
    # for a in article:
    #     print(a)


    # cate = Category.objects.filter(article__title__contains="西游")
    # print(cate.query)

    # article = Article.objects.filter(id__gt=4)
    # print(article.query)
    # print(article)

    # article = Article.objects.filter(title__startswith="西")

    # article = Article.objects.filter(creat_time__range=('2022-02-09', '2022-02-10'))
    article = Article.objects.filter(creat_time__date=('2022-02-09'))
    print(article.query)
    print(article)
    return HttpResponse('hello')
